﻿using System;
using System.Web.Mvc;
using WebApplication1.Models;
using WebApplication1.ViewModels;
namespace WebApplication1.Controllers
{

    /// <summary>
    /// 测试Controller强类型
    /// </summary>
    public class Test5Controller : Controller
    {

        /// <summary>
        /// 由于测试6修改EmployeeViewModel 的 UserName属性，此处出现引用类型错误。   故 Test6以后，Test5无法正常运行
        /// </summary>
        /// <returns></returns>
        // GET: Test5
        public ActionResult Index()
        {
            Employee emp = new Employee();
            emp.FirstName = "Sukesh";
            emp.LastName = "Marla";
            emp.Salary = 20000;
            
            EmployeeViewModel vmEmp = new EmployeeViewModel();
            //vmEmp.EmployeeName = emp.FirstName + " " + emp.LastName;
            vmEmp.Salary = emp.Salary.ToString("C");
            if (emp.Salary > 15000)
            {
                vmEmp.SalaryColor = "yellow";
            }
            else
            {
                vmEmp.SalaryColor = "green";
            }

           
            
            return View("test5", vmEmp);
        }

        public ActionResult AjaxText()
        {
            return View("AjaxText");
        }

        //[Route("/DailyDeal/AjaxText")]   //当路由为   ~//DailyDeal/AjaxText会匹配到方法
        public ActionResult DailyDeal()
        {
            return View("AjaxText");
        }
        
        //public ActionResult ArtistSearch(string q)
        //{
        //    var artists = GetArtists(q);
        //    return PartialView(artists);
        //}

        //private Ilist<Artist> GetArtists(string searchString)
        //{
        //    return storeDB.Artists
        //        .Where(async => a.Name.Contains(searchString))
        //        .ToList();
        //}
    }
}